// const ParentUrl = window.location.protocol+"//"+window.location.host;
const ParentUrl = '';

//获取cookie数据
function getCookie(cookieName) {
    const strCookie = document.cookie
    const cookieList = strCookie.split(';')
    for (let i = 0; i < cookieList.length; i++) {
        const arr = cookieList[i].split('=')
        if (cookieName === arr[0].trim()) {
            return arr[1]
        }
    }
    return ''
}
//删除cookie数据
function deleteCookie(name) {
    this.setCookie(name, "", { expireDays: -1 }); //将过期时间设置为过去来删除一个cookie
}
//获取url值
function getParam(key) {
    var url = window.location.href;
    var params = url.split('?')[1];
    if (params===undefined) return null;//地址无参
    console.log(params);
    var param = params.split('&');
    for(var i = 0; i < param.length; ++i) {
        var paramKeys = param[i].split('=');
        var paramKey = paramKeys[0];
        if(key===paramKey) {
            var value = '';
            for(var j = 1; j < paramKeys.length; ++j) {
                if(paramKeys[j]==='') value+='=';
                else value+=paramKeys[j];
            }
            return value;
        }
    }
    return;
}


const App = {
    mounted() {
    },
    methods: {
        href(url) {
            window.location.href=ParentUrl+url;
        },
        open(url) {
            window.open(ParentUrl+url);
        },
        login(account, password) {
            if (account==='root'&&password==='123456789') {
                this.href('./homepage/index.html');
            } else {
                this.$message({
                    message: '账号或密码错误！',
                    type: 'warning'
                });
            }
        }
    },
    data() {
        return {
            index: 1,
            account: '',
            password: ''
        }
    }
}
const app = Vue.createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(ElementPlus);
app.mount("#app");